package com.hkg.springbootsutdying.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName : RabbitMQConfig
 * @Author : huaikaigang
 * @Date: 2020-07-23 16:02
 * @类描述:
 */
@Configuration
public class RabbitMQConfig {

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topic.exchange");
    }
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct.exchange");
    }
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanout.exchange");
    }
    @Bean
    public Queue queue(){

        return new Queue("topic.queue",false ,false ,false );
    }

    @Bean
    public Binding bindingExchangeTopicQueue1(@Qualifier("queue") Queue queue,
                                             @Qualifier("topicExchange") Exchange exchange){

        return BindingBuilder.bind(queue).to(exchange).with("log.*").noargs();

    }


}
